package com.css.fxfzxczh.modules.earthquakeLossRatio.service.impl;

import com.css.fxfzxczh.modules.earthquakeLossRatio.entity.EarthquakeLossRatio;
import com.css.fxfzxczh.modules.earthquakeLossRatio.repository.EarthquakeLossRatioRepository;
import com.css.fxfzxczh.modules.earthquakeLossRatio.repository.impl.EarthquakeLossRatioRepositoryImpl;
import com.css.fxfzxczh.modules.earthquakeLossRatio.service.EarthquakeLossRatioService;
import com.css.fxfzxczh.util.UUIDGenerator;
import com.css.fxfzxczh.web.PlatformSessionContext;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @Author:
 * @CreateTime: 2024/3/25 16:15
 * @Description:
 */
@Service
public class EarthquakeLossRatioServiceImpl implements EarthquakeLossRatioService {

    @Resource
    EarthquakeLossRatioRepository earthquakeLossRatioRepository;

    @Override
    public void save(EarthquakeLossRatio earthquakeLossRatio) {
        earthquakeLossRatio.setId(UUIDGenerator.getUUID());

        earthquakeLossRatio.setCreateUser(PlatformSessionContext.getUserID());
        earthquakeLossRatio.setCreateTime(new Date());
        earthquakeLossRatioRepository.save(earthquakeLossRatio);
    }

    @Override
    public void update(EarthquakeLossRatio earthquakeLossRatio) {
        earthquakeLossRatio.setUpdateTime(new Date());
        earthquakeLossRatio.setUpdateUser(PlatformSessionContext.getUserID());
        earthquakeLossRatioRepository.update(earthquakeLossRatio);
    }

    @Override
    public EarthquakeLossRatio findById(String xsemId) {

        return earthquakeLossRatioRepository.findById(xsemId);

    }


}
